{
LANG : PASCAL
PROB : calfflac
}

program CALFFLAC;
const
  fi = 'calfflac.in';
  fo = 'calfflac.out';
  letters : set of char = ['A'..'Z', 'a'..'z'];
  maxc = 21000;
type
  xau = record
          l : longint;
          c : array[1..maxc] of char;
        end;
var
  s, a : xau;
  ID : array[1..maxc] of longint;
  d : array[1..maxc] of boolean;
  best, start, finish : longint;
  tren, duoi : byte;

procedure initxau;
begin
  s.l := 0;
  a.l := 0;
end;

procedure inp;
var
  i : longint;
begin
  initxau;
  with s do
    while not eof do
    begin
      while not eoln do
      begin
        inc(l);
        read(c[l]);
        if c[l] in letters then
        begin
          inc(a.l);
          a.c[a.l] := upcase(c[l]);
          ID[a.l] := l;
        end;
      end;
      inc(l);
      c[l] := '$';
      readln;
    end;
end;

function min(x, y : longint) : longint;
begin
  if x > y then min := y
  else min := x;
end;

procedure solve_odd;
var
  i, m : longint;
  ok : boolean;
begin
  fillchar(d, sizeof(d), true);
  m := 3;
  while m <= min(2000, a.l) do
  begin
    ok := false;
    for i := 1 to a.l-m+1 do
      if d[i+1] and (a.c[i] = a.c[i+m-1]) then
      begin
        d[i] := true;
        ok := true;
        if best < m then
        begin
          best := m;
          start := ID[i];
          finish := ID[i+m-1];
        end;
      end
      else d[i] := false;
    if not ok then break;
    inc(m, 2);
  end;
end;

procedure init_even;
var
  i : longint;
begin
  for i := 1 to a.l-1 do
    if a.c[i] = a.c[i+1] then
    begin
      d[i] := true;
      if best < 2 then
      begin
        best := 2;
        start := i;
        finish := i+1;
      end;
    end;
end;

procedure solve_even;
var
  i, m : longint;
  ok : boolean;
begin
  fillchar(d, sizeof(d), false);
  init_even;
  m := 4;
  while m <= min(2000, a.l) do
  begin
    for i := 1 to a.l-m+1 do
      if d[i+1] and (a.c[i] = a.c[i+m-1]) then
      begin
        d[i] := true;
        ok := true;
        if best < m then
        begin
          best := m;
          start := ID[i];
          finish := ID[i+m-1];
        end;
      end
      else d[i] := false;
    if not ok then break;
    inc(m, 2);
  end;
end;

procedure process;
var
  i, j : longint;
begin
  best := 1;
  start := ID[1];
  finish := ID[1];
  solve_odd;
  solve_even;
end;

procedure out;
var
  i : longint;
begin
  writeln(best);
  with s do
    for i := start to finish do
      if c[i] = '$' then writeln
      else write(c[i]);
  writeln;
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);
  inp;
  process;
  out;
  close(output);
  close(input);
end.